<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Tell a Story</title>
    <!-- Basic Page Needs
  ================================================== -->
    <meta charset="utf-8">

    <!-- Bootstrap -->
    <link rel="stylesheet" type="text/css"  href="${pageContext.request.contextPath}/res/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/res/fonts/font-awesome/css/font-awesome.css">

    <!-- Stylesheet
    ================================================== -->
    <link rel="stylesheet" type="text/css"  href="${pageContext.request.contextPath}/res/css/style.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/res/css/responsive.css">
    <script src="${pageContext.request.contextPath}/res/js/jquery-1.11.2.min.js"></script>
    <script src="${pageContext.request.contextPath}/res/js/bootstrap.js"></script>
    <script>
        var onPageNum;
        $(function(){
            onPageNum  =  1;
            $("#FF1").removeClass("active");
            $("#FF2").removeClass("active");
            $("#FF3").addClass("active");
            $("#FF4").removeClass("active");
            $("#FF5").removeClass("active");
            var isSuccess= "${isSuccess}";
            if(isSuccess=="true"){
                $("#alertInfo").show();
                $("#alertInfo").text("操作成功");
                setTimeout(function(){$("#alertInfo").hide();},2000);
            }
            else if(isSuccess=="false"){
                $("#alertWrong").show();
                $("#alertWrong").text("操作失败");
                setTimeout(function(){$("#alertInfo").hide();},2000);
            }
            <% request.getSession().removeAttribute("isSuccess");%>
        });
        function page(goPage) {
            if(goPage=="next"){
                onPageNum = onPageNum+1;
            }
            else if(goPage=="prev"){
                if(onPageNum<=1) return ;
                else onPageNum = onPageNum-1;
            }
            var params = {
                pageNum : onPageNum
            };
            $.ajax({
                type: "POST",
                url: "/column/goPage",
                data: params,
                dataType:"html", //ajax返回值设置为text（json格式也可用它返回，可打印出结果，也可设置成json）
                success: function(data){
                    var columnDTOList = $(data).find("#columnDTOList");

                    if(columnDTOList.html()!=null){
                        $("#column").empty();
                        $("#column").append(columnDTOList).html();
                    }
                    else{
                        onPageNum=onPageNum-1;
                    }
                },
                error: function(data){
                    alert("服务器错误");
                    return false;
                }
            });
        }// end function page
        function deleteArticle(columnID) {
            $('#deleteColumn').modal();
            $("#columnID").val(columnID);
        }
    </script>
</head>
<body>



<!-- Main Navigation
================================================== -->
<jsp:include   page="../nav.jsp" flush="true"/>


<!-- Why Us/Features Section
================================================== -->
<jsp:include   page="sectionHeader.jsp" flush="true"/>



<div id="feature" class="gray-bg"> <!-- fullwidth gray background -->
    <div class="container"> <!-- container -->
        <div class="row" role="tabpanel"> <!-- row -->
            <jsp:include   page="menuOption.jsp" flush="true"/>

            <div class="col-md-6"> <!-- right content col 6 -->
                <!-- Tab panes -->
                <div class="tab-content features-content"> <!-- tab content wrapper -->


                    <!--文章专栏-->
                    <div role="tabpanel" class="tab-pane fade in active" id="f1"> <!-- feature #1 content open -->
                        <ul class="list-inline social">
                            <li><a href="/myBlog/goWriteBlog" class="fa"> <span class="fa fa-pencil"></span></a></li> <!-- facebook link here -->
                            <li><button  class="btn btn-primary tf-btn color" data-toggle="modal" data-target="#newColumn">新建专栏</button></li>
                        </ul>
                        <div id="column">
                            <c:forEach var="column" items="${columnDTOList}" varStatus="vs">
                                <div  id="columnDTOList" class="post-wrap"> <!-- Post Wrapper -->
                                    <div class="media post"> <!-- post wrap -->

                                        <div class="media-body">
                                            <p class="small">${column.genTime}</p>
                                            <a href="/columnArticle/goColumnArticle?columnID=${column.columnID}">
                                                <h5 class="media-heading"><strong>${column.columnName}</strong></h5>
                                            </a>
                                        </div>
                                    </div><!-- end post wrap -->

                                    <div class="post-meta"> <!-- Meta details -->
                                        <ul class="list-inline metas pull-left"> <!-- post metas -->
                                            <li>${column.columnType}</li> <!-- meta author -->
                                            <li><a href="" onclick="deleteArticle('${column.columnID}');return false" >删除</a></li> <!-- meta comments -->
                                        </ul>
                                        <ul class="list-inline meta-detail pull-right"> <!-- user meta interaction -->
                                            <li><i class="fa fa-eye"></i> ${column.readNum}</li> <!-- no. of views -->
                                        </ul>
                                    </div><!-- end Meta details -->
                                </div><!-- end Post Wrapper -->
                            </c:forEach>
                        </div>
                        <c:if test="${columnDTOList!=null}">
                            <div class="text-left"> <!-- Blogrol Pagination -->
                                <nav>
                                    <ul class="pagination">
                                        <li>
                                            <a href="" aria-label="Previous" onclick="page('prev');return false">
                                                <span aria-hidden="true">Prev</span>
                                            </a>
                                        </li>

                                        <li>
                                            <a href="" aria-label="Next" onclick="page('next');return false">
                                                <span aria-hidden="true" >Next</span>
                                            </a>
                                        </li>
                                    </ul>
                                </nav>
                            </div>
                        </c:if>
                    </div>
                    <!--文章专栏-->
                </div> <!-- end tab content wrapper -->
            </div><!-- end right content col 6 -->

        </div> <!-- end row -->
    </div> <!-- end container -->
</div><!-- end fullwidth gray background -->

<!-- Works Section
================================================== -->


<!-- Footer
================================================== -->
<jsp:include   page="../foot.jsp" flush="true"/>


<!-- 删除专栏 模态框（Modal） -->
<div class="modal fade" id="deleteColumn" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">操作提示</h4>
            </div>
            <div id="optionInfo" class="modal-body">删除该专栏，将删除该专栏中的所有文章！确定要删除吗？</div>
            <div id="buttons" class="modal-footer">
                <form action="/column/deleteColumn" method="post">
                    <input id="columnID" name="columnID" type="hidden" />
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-primary">确定</button>
                </form>

            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>



<!-- 新建专栏 模态框（Modal） -->
<div class="modal fade" id="newColumn" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel1">操作提示</h4>
            </div>
            <div id="optionInfo1" class="modal-body"></div>
            <div id="buttons1" class="modal-footer">
                <form action="/column/newColumn" method="post">
                    <div class="form-group">
                    <input name="columnName" type="text" class="form-control input-lg" placeholder="专栏名称">
                    </div>
                    <div class="form-group">
                   <span>专栏类型</span>
                    <select class="form-control" name="columnType">
                        <option>移动开发</option>
                        <option>构架</option>
                        <option>互联网</option>
                        <option>数据库</option>
                    </select>
                    </div>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-primary">确定</button>
                </form>

            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
</body>
</html>
